package com.cui.project.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;

/**
 * 接口流量时序统计表（分钟级）
 * @TableName user_interface_traffic_metrics
 */
@TableName(value ="user_interface_traffic_metrics")
@Data
public class UserInterfaceTrafficMetrics implements Serializable {
    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 接口ID
     */
    @TableField(value = "interface_info_id")
    private Long interfaceInfoId;

    /**
     * 时间桶（精确到分钟）
     */
    @TableField(value = "time_bucket")
    private Date timeBucket;

    /**
     * 请求次数
     */
    @TableField(value = "request_count")
    private Integer requestCount;

    /**
     * 成功次数
     */
    @TableField(value = "success_count")
    private Integer successCount;

    /**
     * 失败次数
     */
    @TableField(value = "fail_count")
    private Integer failCount;

    /**
     * 平均响应时间（毫秒）
     */
    @TableField(value = "avg_latency_ms")
    private Integer avgLatencyMs;

    /**
     * 最大响应时间
     */
    @TableField(value = "max_latency_ms")
    private Integer maxLatencyMs;

    /**
     * 总请求体大小（字节）
     */
    @TableField(value = "total_body_size")
    private Long totalBodySize;

    /**
     * 独立用户数
     */
    @TableField(value = "unique_users")
    private Integer uniqueUsers;

    /**
     * 独立IP数
     */
    @TableField(value = "unique_ips")
    private Integer uniqueIps;

    /**
     * 
     */
    @TableField(value = "created_at")
    private Date createdAt;

    /**
     * 
     */
    @TableField(value = "user_id")
    private Long userId;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        UserInterfaceTrafficMetrics other = (UserInterfaceTrafficMetrics) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getInterfaceInfoId() == null ? other.getInterfaceInfoId() == null : this.getInterfaceInfoId().equals(other.getInterfaceInfoId()))
            && (this.getTimeBucket() == null ? other.getTimeBucket() == null : this.getTimeBucket().equals(other.getTimeBucket()))
            && (this.getRequestCount() == null ? other.getRequestCount() == null : this.getRequestCount().equals(other.getRequestCount()))
            && (this.getSuccessCount() == null ? other.getSuccessCount() == null : this.getSuccessCount().equals(other.getSuccessCount()))
            && (this.getFailCount() == null ? other.getFailCount() == null : this.getFailCount().equals(other.getFailCount()))
            && (this.getAvgLatencyMs() == null ? other.getAvgLatencyMs() == null : this.getAvgLatencyMs().equals(other.getAvgLatencyMs()))
            && (this.getMaxLatencyMs() == null ? other.getMaxLatencyMs() == null : this.getMaxLatencyMs().equals(other.getMaxLatencyMs()))
            && (this.getTotalBodySize() == null ? other.getTotalBodySize() == null : this.getTotalBodySize().equals(other.getTotalBodySize()))
            && (this.getUniqueUsers() == null ? other.getUniqueUsers() == null : this.getUniqueUsers().equals(other.getUniqueUsers()))
            && (this.getUniqueIps() == null ? other.getUniqueIps() == null : this.getUniqueIps().equals(other.getUniqueIps()))
            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getInterfaceInfoId() == null) ? 0 : getInterfaceInfoId().hashCode());
        result = prime * result + ((getTimeBucket() == null) ? 0 : getTimeBucket().hashCode());
        result = prime * result + ((getRequestCount() == null) ? 0 : getRequestCount().hashCode());
        result = prime * result + ((getSuccessCount() == null) ? 0 : getSuccessCount().hashCode());
        result = prime * result + ((getFailCount() == null) ? 0 : getFailCount().hashCode());
        result = prime * result + ((getAvgLatencyMs() == null) ? 0 : getAvgLatencyMs().hashCode());
        result = prime * result + ((getMaxLatencyMs() == null) ? 0 : getMaxLatencyMs().hashCode());
        result = prime * result + ((getTotalBodySize() == null) ? 0 : getTotalBodySize().hashCode());
        result = prime * result + ((getUniqueUsers() == null) ? 0 : getUniqueUsers().hashCode());
        result = prime * result + ((getUniqueIps() == null) ? 0 : getUniqueIps().hashCode());
        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", interfaceInfoId=").append(interfaceInfoId);
        sb.append(", timeBucket=").append(timeBucket);
        sb.append(", requestCount=").append(requestCount);
        sb.append(", successCount=").append(successCount);
        sb.append(", failCount=").append(failCount);
        sb.append(", avgLatencyMs=").append(avgLatencyMs);
        sb.append(", maxLatencyMs=").append(maxLatencyMs);
        sb.append(", totalBodySize=").append(totalBodySize);
        sb.append(", uniqueUsers=").append(uniqueUsers);
        sb.append(", uniqueIps=").append(uniqueIps);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", userId=").append(userId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}